//
//  SelectFeatureVC.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/2.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "SelectFeatureVC.h"
#import "TagsListCell.h"
@interface SelectFeatureVC ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UIButton *bottomBtn;

@end

@implementation SelectFeatureVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.tableview.delegate = self;
    
    self.tableview.dataSource = self;
    
    self.tableview.backgroundColor = [UIColor clearColor];
    
    self.tableview.tableFooterView = [[UIView alloc]init];
    
    self.tableview.showsVerticalScrollIndicator = NO;
    
    
    
    self.tableview.rowHeight = 50;
    
    self.topLabel.font = MYFONT(17);
    
    self.bottomBtn.titleLabel.font = MYFONT(17);
    
    
    
    [self.tableview registerNib:[UINib nibWithNibName:NSStringFromClass([TagsListCell class]) bundle:nil] forCellReuseIdentifier:[TagsListCell identifierStr]];

    // Do any additional setup after loading the view.
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return  self.model.language.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    TagsListCell *temp = (TagsListCell *)[tableView dequeueReusableCellWithIdentifier:[TagsListCell identifierStr]];
    
    temp.model = self.model.language[indexPath.row];
    
    return temp;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    HouseParameSub *model = self.model.language[indexPath.row];
    
    if ([model.isSelect isEqualToString:@"1"]) {
        model.isSelect = @"0";
    } else {
        
        
        int k = 0;
        for (HouseParameSub *sub in self.model.language) {
            if ([sub.isSelect isEqualToString:@"1"]) {
                k += 1;
            }
        }
        
        if (k == 3 ) {
            
            
            [SVProgressHUD showInfoWithStatus:@"亲!最多选三个..."];
            
        }else{
            
            model.isSelect = @"1";
            
        }
        
        
    }
    
    [self.tableview reloadData];
    
    
//    [self dismissViewControllerAnimated:YES completion:nil];
    
}




- (IBAction)sureBtndidTap:(UIButton *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"TagsDidFilishSelet" object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
